<?php

namespace app\api\controller;


use app\api\validate\User;
use app\BaseController;
use app\common\lib\sms\ZhenziSmsClient;
use think\exception\ValidateException;

class Sms extends BaseController
{
    public function code() {
        $phone_number = input('param.phone_number','','trim');
        try{
            validate(User::class)->scene("send_code")->check(compact('phone_number'));
        }catch (ValidateException $e){
            return show(config('status.error'),$e->getError());
        }
        $result =  \app\common\business\Sms::sendCode($phone_number,6);
        if($result){
            return show(config("status.success"),"ok");
        }else{
            return show(config("status.error"),"失败");
        }

    }
}